package com.ruoyi.system.service.impl;

import java.util.Collections;
import java.util.List;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.system.domain.vo.TbDeviceVO;
import com.ruoyi.system.mapper.TbDeviceMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.TbDeviceDataPackagesMapper;
import com.ruoyi.system.domain.TbDeviceDataPackages;
import com.ruoyi.system.service.ITbDeviceDataPackagesService;

import javax.annotation.Resource;

/**
 * 设备安装数据包信息Service业务层处理
 *
 * @author ruoyi
 * @date 2025-08-11
 */
@Service
public class TbDeviceDataPackagesServiceImpl implements ITbDeviceDataPackagesService {
    @Autowired
    private TbDeviceDataPackagesMapper tbDeviceDataPackagesMapper;


    @Resource
    private TbDeviceMapper tbDeviceMapper;

    /**
     * 查询设备安装数据包信息
     *
     * @param id 设备安装数据包信息主键
     * @return 设备安装数据包信息
     */
    @Override
    public TbDeviceDataPackages selectTbDeviceDataPackagesById(Long id) {
        return tbDeviceDataPackagesMapper.selectTbDeviceDataPackagesById(id);
    }

    /**
     * 查询设备安装数据包信息列表
     *
     * @param tbDeviceDataPackages 设备安装数据包信息
     * @return 设备安装数据包信息
     */
    @Override
    public List<TbDeviceDataPackages> selectTbDeviceDataPackagesList(TbDeviceDataPackages tbDeviceDataPackages) {
        return tbDeviceDataPackagesMapper.selectTbDeviceDataPackagesList(tbDeviceDataPackages);
    }

    /**
     * 新增设备安装数据包信息
     *
     * @param tbDeviceDataPackages 设备安装数据包信息
     * @return 结果
     */
    @Override
    public int insertTbDeviceDataPackages(TbDeviceDataPackages tbDeviceDataPackages) {
        tbDeviceDataPackages.setCreateTime(DateUtils.getNowDate());
        return tbDeviceDataPackagesMapper.insertTbDeviceDataPackages(tbDeviceDataPackages);
    }

    /**
     * 修改设备安装数据包信息
     *
     * @param tbDeviceDataPackages 设备安装数据包信息
     * @return 结果
     */
    @Override
    public int updateTbDeviceDataPackages(TbDeviceDataPackages tbDeviceDataPackages) {
        tbDeviceDataPackages.setUpdateTime(DateUtils.getNowDate());
        return tbDeviceDataPackagesMapper.updateTbDeviceDataPackages(tbDeviceDataPackages);
    }

    /**
     * 批量删除设备安装数据包信息
     *
     * @param ids 需要删除的设备安装数据包信息主键
     * @return 结果
     */
    @Override
    public int deleteTbDeviceDataPackagesByIds(Long[] ids) {
        return tbDeviceDataPackagesMapper.deleteTbDeviceDataPackagesByIds(ids);
    }

    /**
     * 删除设备安装数据包信息信息
     *
     * @param id 设备安装数据包信息主键
     * @return 结果
     */
    @Override
    public int deleteTbDeviceDataPackagesById(Long id) {
        return tbDeviceDataPackagesMapper.deleteTbDeviceDataPackagesById(id);
    }

    @Override
    public List<TbDeviceVO> selectTbDevicesList(TbDeviceDataPackages tbDeviceDataPackages) {
        List<String> deviceSnList = tbDeviceDataPackagesMapper.selectTbDevicesList(tbDeviceDataPackages);
        if (deviceSnList != null && deviceSnList.size() > 0) {
            List<TbDeviceVO> tbDeviceVOList = tbDeviceMapper.selectListByDeviceSns(deviceSnList);
            return tbDeviceVOList;

        }
        return Collections.emptyList();
    }
}
